<?php
namespace Home\Controller;
use Think\Controller;

class OrderController extends Controller{
	public function orderList(){
		//$uname = $_SESSION['uname']=0;
		$res = M('order')->order("ordtime desc")->select();
		$re  = M('order')->select();
		$dfk = M('order')->where("ordnow=2")->count();
		$dfh = M('order')->where("ordnow=3")->count();
		$dsh = M('order')->where("ordnow=4")->count();
		$dpj = M('order')->where("ordnow=5")->count();
		//print_r($res);
		$pro =array();
		foreach($re as $v){
			$pro[] = json_decode($v["pro"],true);
		}
		$this->assign("res",$res);
		$this->assign("pro",$pro);
		//print_r($pro);
		$this->assign("dfk",$dfk);
		$this->assign("dfh",$dfh);
		$this->assign("dsh",$dsh);
		$this->assign("dpj",$dpj);
		$this->display();
	}
	
	public function ordnowSave(){
		$oid = I("get.oid");
		$res = D('order');		
		$r = array();
		if($res->where(array("ordid"=>"{$oid}"))->save(array("ordnow"=>"6"))){
			$r['status']=true;
		}else{
			$r['status']=false;
		}
		$this->ajaxReturn($r);
	}

	public function orderDel(){
		$oid = I("get.oid");
		$res = D('order');		
		$r = array();
		if($res->where(array("ordid"=>"{$oid}"))->delete()){
			$r['status']=true;
		}else{
			$r['status']=false;
		}
		$this->ajaxReturn($r);
	}

	public function orderSure(){
		$oid = I("get.oid");
		$res = D('order');		
		$r = array();
		if($res->where(array("ordid"=>"{$oid}"))->save(array("ordnow"=>"5"))){
			$r['status']=true;
		}else{
			$r['status']=false;
		}
		$this->ajaxReturn($r);
	}


}